package Day06嵌套_随机数_breakcontinue;

import java.util.Random;
import java.util.Scanner;

public class SuiJiShu {
        public static void main(String[] args) {
            Random ran = new Random();
            Scanner sc = new Scanner(System.in);
            int i = ran.nextInt(100) + 1;
            System.out.println(i);

            int count = 0;

            for (; ; ) {
                System.out.println("请输入一个1~100的整数:");
                int i1 = sc.nextInt();

                if (i1 > i) {
                    System.out.println("您输入的数字大了!");
                    count++;
                    if (count == 5) {
                        System.out.println("您没有机会了!");
                        System.exit(0);
                    }
                } else if (i1 < i) {
                    System.out.println("您输入的数字小了!");
                    count++;
                    if (count == 5) {
                        System.out.println("您没有机会了!");
                        System.exit(0);
                    }
                } else if (i1 == i) {
                    System.out.println("您猜对了!");
                    System.exit(0); // break; 结束循环
                }
            }
        }
    }
//****************int ran = ran.nextInt(100) + 1; 最小0+1,最大99+1 ;*******************************

